package com.ocean.clearance.service.impl;

import java.time.LocalDateTime;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import com.rabbitmq.client.Channel;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class RabbitConsumerDemo {

	@RabbitListener(queues = "ldy_test_rece")

	@SneakyThrows
    public void process(String msg,Channel channel,@Header(AmqpHeaders.DELIVERY_TAG) long tag) {
        log.info("接收消息:"+LocalDateTime.now().toString()+" 内容："+msg);
		channel.basicAck(tag,true);//手动ack，确保不丢单
    }
	
}
